#include "GameObject.h"

#include <gtc/matrix_transform.hpp>
#include <gtx/quaternion.hpp>

// CoreLib
#include "MathConstants.h"

le::GameObject::GameObject()
	: m_Position(0.f)
	, m_Scale(1.f)
	, m_Rotation(0.f, 0.f, 0.f, 0.f)
{
	
}

le::GameObject::~GameObject()
{

}

void le::GameObject::SetRotation( float xRotation, float yRotation, float zRotation )
{
	m_Rotation = glm::quat(1.f, xRotation, yRotation, zRotation);
}

void le::GameObject::SetScale( float scale )
{
	m_Scale = glm::vec3(scale);
}

void le::GameObject::SetScale( float x, float y, float z )
{
	m_Scale = glm::vec3(x, y, z);
}

glm::mat4x4 le::GameObject::GetWorldMatrix() const
{
	// Start off with the identity matrix
	glm::mat4 outMatrix;

	// Scale the object around the origin
	outMatrix = glm::scale(outMatrix, m_Scale);

	// Rotate the object around the origin
	outMatrix = outMatrix * glm::toMat4(m_Rotation);

	// Finally place it where it should belong in the world
	outMatrix = glm::translate(outMatrix, m_Position);

	return outMatrix;
}
